<%--
    Document   : todasReservas
    Created on : 12/10/2011, 20:16:28
    Author     : Neto
--%>
<%@page import="model.Voo, model.Usuario"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.util.List, java.util.Iterator, javax.servlet.http.HttpSession;"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>LISTAGEM DE TODAS AS RESERVAS FEITAS</title>
    </head>
    <body>
         <jsp:include page="topoadmin.jsp"/>
    <body >
        <%
            HttpSession sessao = request.getSession(true);
            try {
                Usuario usuarioAdmin = (Usuario) sessao.getAttribute("admin");
                Usuario usuario = (Usuario) sessao.getAttribute("usuario");
                if(usuario.getCpf() == null){
                    response.sendRedirect("login.jsp");
                }else if(usuarioAdmin.getLogin().equals("admin") && usuarioAdmin.getSenha().equals("admin")){

        %>

        <div id="content">
            <br><br>
             <table style="text-align: left; width: 80%;" border="1" cellpadding="2" cellspacing="2" align="center">
            <tbody>
                <tr>
                    <td style="vertical-align: top; text-align: center;"><b>Numero do VOO</b></td>
                    <td style="vertical-align: top; text-align: center;"><b>Local de Origem</b></td>
                    <td style="vertical-align: top; text-align: center;"><b>Local de Destino</b></td>
                    <td style="vertical-align: top; text-align: center;"><b>Data</b></td>
                    <td style="vertical-align: top; text-align: center;"><b>Hora</b></td>
                    <td style="vertical-align: top; text-align: center;"><b>Excluir</b></td>
                </tr>
                <%
                    List voos = (List)request.getAttribute("todosVoos");
                    for (Iterator i = voos.iterator(); i.hasNext();){
                    Voo v= (Voo)i.next();
                %>
                <tr>
                    <td style="vertical-align: top; text-align: center;"><%= v.getNumVoo() %></td>
                    <td style="vertical-align: top; text-align: center;"><%= v.getLocalOrigem() %></td>
                    <td style="vertical-align: top; text-align: center;"><%= v.getLocalDestino() %></td>
                    <td style="vertical-align: top; text-align: center;"><%= v.getData() %></td>
                    <td style="vertical-align: top; text-align: center;"><%= v.getHora() %></td>
                    <td style="vertical-align: top; text-align: center;">
                        <a href="controlador?cmd=excluirVoo&numVoo=<%= v.getNumVoo()%>">Excluir</a>
                    </td>
                </tr>
                <%
                            }
                %>

            </tbody>
        </table>
        </div>
                 <%
                }
            } catch (Exception e) {
                e.printStackTrace();
                response.sendRedirect("login.jsp");
            }

        %>
    </body>
    <jsp:include page="rodape.jsp"/>
